package com.lxw.oa.util;

import java.sql.*;

/**
 * Created by Administrator on 2019/4/24.
 */
public class ImpalaJdbc {

    private static String driverName ="org.apache.hive.jdbc.HiveDriver";
    public static void main(String[] args)throws SQLException {

        Connection con = null;
        ResultSet rs = null;
        PreparedStatement ps = null;
        try {
            Class.forName(driverName);
            con = DriverManager.getConnection("jdbc:hive2://192.168.5.70:21050/;auth=noSasl");
            ps = con.prepareStatement("select count(*)  from dblab.bigdata_user");
            rs = ps.executeQuery();
        while (rs.next()) {
            System.out.println(rs.getString(1));
        }

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            System.exit(1);
        }finally{
        try {
            ps.close();
            rs.close();
            con.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    }

}
